﻿using System.Collections.Generic;
using System.Windows.Forms;
using Mini.Resource;

namespace Mini.DownloadTool
{
    public class ValidationHelper
    {
        public static List<string> ControlNameList = new List<string>()
            {
                "txtSiteName",
                "dgvListPage"
            };

        public static bool ValidationTextBoxAfterStart(Form form)
        {
            foreach (var controlName in ControlNameList)
            {
                var control = form.Controls[controlName];
                var textbox = control as TextBox;
                if (textbox != null)
                {
                    if (!string.IsNullOrWhiteSpace(textbox.Text)) continue;
                    MessageBox.Show(MessageResource.FolderRequired, MessageResource.WarningTitle);
                    textbox.Focus();
                    return false;
                }

                var dataGridView = control as DataGridView;
                if (dataGridView == null) continue;
                if (dataGridView.Rows.Count != 0) continue;
                MessageBox.Show(MessageResource.PageRequired, MessageResource.WarningTitle);
                return false;
            }
            return true;
        }

    }
}
